package com.atguigu3.dao;

import com.beans.Customers;
import com.utils.JDBCUtilsJiuBan;
import org.junit.Test;

import java.sql.Connection;
import java.util.List;

/**
 * @auther user
 * @date 2021/12/10 - 3:18
 */
public class CustomersDaoImplTest {
    com.atguigu3.dao.CustomersDaoImpl dao = new CustomersDaoImpl();

    @Test
    public void getCustomersById() {
        Connection connection = null;
        try {
            connection = JDBCUtilsJiuBan.getConnection();
            Customers customers = dao.getCustomersById(connection,19);
            System.out.println(customers);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            JDBCUtilsJiuBan.closeResource(connection,null);
        }
    }

    @Test
    public void getAll() {
        Connection connection = null;
        try {
            connection = JDBCUtilsJiuBan.getConnection();
            List<Customers> list = dao.getAll(connection);
            list.forEach(System.out::println);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            JDBCUtilsJiuBan.closeResource(connection,null);
        }
    }
}